package com.fancy.learncenter.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.activity.base.BaseActivity;
import com.fancy.learncenter.ui.view.TopBanner;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class GuideActivity extends BaseActivity {

    @Bind(R.id.guide)
    TopBanner guide;

    List<Integer> data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide, Status.STATUS);
        ButterKnife.bind(this);

        data = new ArrayList<>();


        data.add(R.mipmap.guide1);
        data.add(R.mipmap.guide2);
        data.add(R.mipmap.guide3);

        guide.setResData(data, R.layout.activity_guide_item);
        guide.setBindViewCallBack(new TopBanner.BindViewCallBack<Integer>() {
            @Override
            public void bindView(View rootView, int position, Integer itemData) {
                ImageView guide_bg = (ImageView) rootView.findViewById(R.id.guide_bg);
                guide_bg.setImageResource(itemData);

                if (position == data.size() - 1) {
                    Button start = (Button) rootView.findViewById(R.id.start);
                    start.setVisibility(View.VISIBLE);

                    start.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(GuideActivity.this, MainActivity.class);
                            startActivity(intent);
                            finish();
                        }
                    });
                }
            }
        });
    }
}


